Browse Source

Media and MovieCell: Check for optimizeItemName and remove extension accordingly

(closes #485)
Carola Nitz 6 years ago
parent
commit
41836cabaf

+ 10 - 2
Sources/MediaCategoryCells/MediaCollectionViewCell.swift

@@ -60,7 +60,11 @@ class MediaCollectionViewCell: BaseCollectionViewCell {
     }
 
     func update(audiotrack: VLCMLMedia) {
-        titleLabel.text = audiotrack.title
+        var title = audiotrack.title
+        if  UserDefaults.standard.bool(forKey: kVLCOptimizeItemNamesForDisplay) == true {
+            title = (title as NSString).deletingPathExtension
+        }
+        titleLabel.text = title
         accessibilityLabel = audiotrack.accessibilityText(editing: false)
         descriptionLabel.text = audiotrack.albumTrackArtistName()
         newLabel.isHidden = !audiotrack.isNew
@@ -84,7 +88,11 @@ class MediaCollectionViewCell: BaseCollectionViewCell {
     }
 
     func update(movie: VLCMLMedia) {
-        titleLabel.text = movie.title
+        var title = movie.title
+        if  UserDefaults.standard.bool(forKey: kVLCOptimizeItemNamesForDisplay) == true {
+            title = (title as NSString).deletingPathExtension
+        }
+        titleLabel.text = title
         accessibilityLabel = movie.accessibilityText(editing: false)
         descriptionLabel.text = movie.mediaDuration()
         if movie.isThumbnailGenerated() {

+ 5 - 1
Sources/MediaCategoryCells/MovieCollectionViewCell.swift

@@ -58,7 +58,11 @@ class MovieCollectionViewCell: BaseCollectionViewCell {
     }
 
     func update(movie: VLCMLMedia) {
-        titleLabel.text = movie.title
+        var title = movie.title
+        if UserDefaults.standard.bool(forKey: kVLCOptimizeItemNamesForDisplay) == true {
+            title = (title as NSString).deletingPathExtension
+        }
+        titleLabel.text = title
         accessibilityLabel = movie.accessibilityText(editing: false)
         descriptionLabel.text = movie.mediaDuration()
         thumbnailView.image = movie.thumbnailImage()

+ 1 - 0
Sources/VLCConstants.h

@@ -18,6 +18,7 @@
 #define kVLCSettingPasscodeAllowFaceID @"AllowFaceID"
 #define kVLCThemeDidChangeNotification @"themeDidChangeNotfication"
 #define kVLCSettingAppTheme @"darkMode"
+#define kVLCOptimizeItemNamesForDisplay @"MLDecrapifyTitles"
 #define kVLCSettingAbout @"about"
 #define kVLCAutomaticallyPlayNextItem @"AutomaticallyPlayNextItem"
 #define kVLCSettingContinueAudioInBackgroundKey @"BackgroundAudioPlayback"