diff --git a/Podfile b/Podfile index b568231e66c61e93b347db19fc1eae2de4abd8ea..cbd4971f01a7b94a5ea6e2fb8a71e0bc92507e13 100644 --- a/Podfile +++ b/Podfile @@ -8,7 +8,7 @@ def shared_pods pod 'CocoaHTTPServer', :git => 'https://code.videolan.org/fkuehne/CocoaHTTPServer.git', :commit => '08f9b818' pod 'AFNetworking', :git => 'https://code.videolan.org/fkuehne/AFNetworking.git', :commit => 'ee51009a' # add visionOS support pod 'VLCKit', '4.0.0a10' - pod 'VLCMediaLibraryKit', '0.13.0a10' + pod 'VLCMediaLibraryKit', '0.13.0a11' end target 'VLC-iOS' do diff --git a/Podfile.lock b/Podfile.lock index 8cd1fb3e9dee935978f6996e05d586af16d84077..30aed5be3efa84440b4e42bafe60d57e1402dda8 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -73,7 +73,7 @@ PODS: - SimulatorStatusMagic (2.7) - SwiftLint (0.50.3) - VLCKit (4.0.0a10) - - VLCMediaLibraryKit (0.13.0a10): + - VLCMediaLibraryKit (0.13.0a11): - VLCKit (>= 4.0.0a10) - XKKeychain (1.0.1) @@ -96,7 +96,7 @@ DEPENDENCIES: - SimulatorStatusMagic - SwiftLint (~> 0.50.3) - VLCKit (= 4.0.0a10) - - VLCMediaLibraryKit (= 0.13.0a10) + - VLCMediaLibraryKit (= 0.13.0a11) - XKKeychain (from `https://code.videolan.org/fkuehne/XKKeychain.git`, commit `40abb8f1`) SPEC REPOS: @@ -200,9 +200,9 @@ SPEC CHECKSUMS: SimulatorStatusMagic: 4e15e56530b367e90dcd3b94fd272e833e9d8a44 SwiftLint: 77f7cb2b9bb81ab4a12fcc86448ba3f11afa50c6 VLCKit: e21135aece10e3aa89e34020b7112b73d7cc98e6 - VLCMediaLibraryKit: 59c58376b7592e9a1b14106dfc24c40d854bb740 + VLCMediaLibraryKit: 5bbd1dd300e88b8df607077b2b01b6952c8d48fb XKKeychain: 160ce5bfeff49e9fef091f7fc2b2fe5a5aa08e08 -PODFILE CHECKSUM: 08c77786bb3b3cd075029e8f71fc44c305f3f101 +PODFILE CHECKSUM: 65a7fa9ee482022fade614219df0522c6399aafe COCOAPODS: 1.15.2 diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index 84b29ec73724b1cd82b3f91659c8eba014a8ae62..05401c5a2c34678f8b0703922ee5c7c802ccdd63 100644 --- a/Resources/en.lproj/Localizable.strings +++ b/Resources/en.lproj/Localizable.strings @@ -432,6 +432,7 @@ "NB_ALBUM" = "Number of albums"; "LAST_PLAYBACK_DATE" = "Last playback date"; "TRACK_ID" = "Track ID"; +"CUSTOM" = "Custom"; // MARK: - VLCNetworkLoginTVViewController diff --git a/Sources/Media Library/Editing/EditController.swift b/Sources/Media Library/Editing/EditController.swift index 1d832e54a27419115a9016347fa3b25c94933f1e..ff47d4a51a88271b6a724855d00b5ec31aa3ae75 100644 --- a/Sources/Media Library/Editing/EditController.swift +++ b/Sources/Media Library/Editing/EditController.swift @@ -393,7 +393,9 @@ extension EditController: UICollectionViewDataSource { if let cell = cell as? MediaCollectionViewCell { cell.showCheckmark(true) cell.disableScrollView() - if let collectionModel = model as? CollectionModel, collectionModel.mediaCollection is VLCMLPlaylist { + if let collectionModel = model as? CollectionModel, + collectionModel.mediaCollection is VLCMLPlaylist, + collectionModel.sortModel.currentSort == .default { cell.dragIndicatorImageView.isHidden = false } else if cell.media is VLCMLMediaGroup || cell.media is VLCMLPlaylist { cell.dragIndicatorImageView.isHidden = true @@ -427,9 +429,12 @@ extension EditController: UICollectionViewDataSource { } func collectionView(_ collectionView: UICollectionView, canMoveItemAt indexPath: IndexPath) -> Bool { - if let collectionModel = model as? CollectionModel, collectionModel.mediaCollection is VLCMLPlaylist { + if let collectionModel = model as? CollectionModel, + collectionModel.mediaCollection is VLCMLPlaylist, + collectionModel.sortModel.currentSort == .default { return true } + return false } diff --git a/Sources/Media Library/MediaLibraryModel/CollectionModel.swift b/Sources/Media Library/MediaLibraryModel/CollectionModel.swift index 9bd87f214be04a9b3cac52b6c72d9a0cbf5f9242..3624df87e093f45b75e2fa266039b9adc4d3d38e 100644 --- a/Sources/Media Library/MediaLibraryModel/CollectionModel.swift +++ b/Sources/Media Library/MediaLibraryModel/CollectionModel.swift @@ -50,6 +50,11 @@ class CollectionModel: MLBaseModel { } self.medialibrary = mediaService self.mediaCollection = mediaCollection + + if mediaCollection is VLCMLPlaylist { + sortModel.sortingCriteria.append(.default) + } + self.sortModel = mediaCollection.sortModel() ?? self.sortModel var sortingCriteria: VLCMLSortingCriteria = .default diff --git a/Sources/Media Library/MediaLibraryModel/PlaylistModel.swift b/Sources/Media Library/MediaLibraryModel/PlaylistModel.swift index 25c1e973220ac424dfdb39742ded4d9b91322d0e..ad14f4dd11a1f5fbc4af30c7bddcaba7f6731081 100644 --- a/Sources/Media Library/MediaLibraryModel/PlaylistModel.swift +++ b/Sources/Media Library/MediaLibraryModel/PlaylistModel.swift @@ -216,7 +216,7 @@ extension VLCMLPlaylist: MediaCollectionModel { func files(with criteria: VLCMLSortingCriteria = .alpha, desc: Bool = false) -> [VLCMLMedia]? { - return media + return media(with: criteria, desc: desc) } func title() -> String { diff --git a/Sources/Media Library/MediaLibraryModel/SortModel.swift b/Sources/Media Library/MediaLibraryModel/SortModel.swift index 3b22b81cb412753df801942355551d1fbb88a97d..806fd8ab8d2c918561d0342f96b2c8b29a111d75 100644 --- a/Sources/Media Library/MediaLibraryModel/SortModel.swift +++ b/Sources/Media Library/MediaLibraryModel/SortModel.swift @@ -71,7 +71,7 @@ extension VLCMLSortingCriteria: CustomStringConvertible { case .trackID: return NSLocalizedString("TRACK_ID", comment: "") case .default: - return NSLocalizedString("DEFAULT", comment: "") + return NSLocalizedString("CUSTOM", comment: "") @unknown default: return NSLocalizedString("DEFAULT", comment: "") } diff --git a/Sources/Media Library/MediaViewControllers/MediaViewController.swift b/Sources/Media Library/MediaViewControllers/MediaViewController.swift index 3077251a6fb2dc5fca449c9e3efbe69288c3257e..cc5a8ee18f5f8f6030df6d7c0941b3a297c581a7 100644 --- a/Sources/Media Library/MediaViewControllers/MediaViewController.swift +++ b/Sources/Media Library/MediaViewControllers/MediaViewController.swift @@ -452,8 +452,12 @@ extension MediaViewController { for (index, criterion) in sortModel.sortingCriteria.enumerated() { let currentSort: Bool = index == currentSortIndex let chevronImageName: String = sortModel.desc ? "chevron.down" : "chevron.up" - let actionImage: UIImage? = currentSort ? - UIImage(systemName: chevronImageName) : nil + var actionImage: UIImage? = currentSort ? UIImage(systemName: chevronImageName) : nil + + // There is no need to display the desc image since it has no impact + if criterion == VLCMLSortingCriteria.default { + actionImage = nil + } let action = UIAction(title: String(describing: criterion), image: actionImage, @@ -513,11 +517,6 @@ extension MediaViewController { var rightMenuItems: [UIMenuElement] = [selectAction] - if let model = mediaCategoryViewController.model as? CollectionModel, - model.mediaCollection is VLCMLPlaylist { - return UIMenu(options: .displayInline, children: rightMenuItems) - } - if let parentViewController = viewController?.parent, parentViewController is VideoViewController || parentViewController is AudioViewController { let historyMenu = generateHistoryMenu() @@ -527,6 +526,12 @@ extension MediaViewController { let layoutSubMenu = generateLayoutMenu(with: mediaCategoryViewController) let sortSubMenu = generateSortMenu(with: mediaCategoryViewController) + if let model = mediaCategoryViewController.model as? CollectionModel, + model.mediaCollection is VLCMLPlaylist { + rightMenuItems.append(sortSubMenu) + return UIMenu(options: .displayInline, children: rightMenuItems) + } + rightMenuItems.append(layoutSubMenu) rightMenuItems.append(sortSubMenu)