소스 검색

Media and MovieCell: Check for optimizeItemName and remove extension accordingly

(closes #485)
Carola Nitz 6 년 전
부모
커밋
41836cabaf
3개의 변경된 파일16개의 추가작업 그리고 3개의 파일을 삭제
  1. 10 2
      Sources/MediaCategoryCells/MediaCollectionViewCell.swift
  2. 5 1
      Sources/MediaCategoryCells/MovieCollectionViewCell.swift
  3. 1 0
      Sources/VLCConstants.h

+ 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"