Quellcode durchsuchen

Settings: Add a button to force medialibrary rescan

Edgar Fouillet vor 5 Jahren
Ursprung
Commit
0bb59355a9

+ 10 - 0
Resources/Settings.bundle/Root.inApp.plist

@@ -608,6 +608,16 @@
 		</dict>
 		<dict>
 			<key>DefaultValue</key>
+			<integer>0</integer>
+			<key>Type</key>
+			<string>IASKButtonSpecifier</string>
+			<key>Key</key>
+			<string>forceMediaLibraryRescan</string>
+			<key>Title</key>
+			<string>SETTINGS_MEDIA_LIBRARY_RESCAN</string>
+		</dict>
+		<dict>
+			<key>DefaultValue</key>
 			<true/>
 			<key>Key</key>
 			<string>MLDecrapifyTitles</string>

+ 1 - 0
Resources/Settings.bundle/en.lproj/Root.strings

@@ -87,6 +87,7 @@
 "SETTINGS_SEND_RATING" = "Please Rate VLC for iOS";
 
 "SETTINGS_MEDIA_LIBRARY" = "Media library";
+"SETTINGS_MEDIA_LIBRARY_RESCAN" = "Force VLC to rescan the media library";
 "SETTINGS_DECRAPIFY" = "Optimize item names for display";
 
 "SETTINGS_FILE_SYNC" = "File Synchronization";

+ 5 - 0
Resources/en.lproj/Localizable.strings

@@ -68,6 +68,7 @@
 "BUTTON_CONTINUE" = "Continue";
 "BUTTON_SET" = "Set";
 "BUTTON_RESET" = "Reset";
+"BUTTON_RESCAN" = "Rescan";
 "PRIVATE_PLAYBACK_TOGGLE" = "Private Playback";
 "SCAN_SUBTITLE_TOGGLE" = "Scan for Subtitles (http-only)";
 
@@ -386,3 +387,7 @@
 /* MediaMoreOptionsActionSheet */
 "EQUALIZER_CELL_TITLE" = "Equalizer";
 "MORE_OPTIONS_HEADER_TITLE" = "Video Options";
+
+/* Settings - Force rescan alert */
+"FORCE_RESCAN_TITLE" = "Force media library rescan";
+"FORCE_RESCAN_MESSAGE" = "Do you want to force VLC to rescan your media library?\nIt could take some time.";

+ 30 - 0
Sources/VLCSettingsController.m

@@ -216,6 +216,8 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV
 
     if ([specifier.type isEqualToString: kIASKPSMultiValueSpecifier]) {
         [self displayActionSheetFor:specifier];
+    } else if ([specifier.type isEqualToString: kIASKButtonSpecifier]) {
+        [self buttonTappedFor:specifier];
     } else {
         [super tableView:tableView didSelectRowAtIndexPath:indexPath];
     }
@@ -237,4 +239,32 @@ NSString * const kVLCSectionTableHeaderViewIdentifier = @"VLCSectionTableHeaderV
     }];
 }
 
+- (void)buttonTappedFor:(IASKSpecifier *)specifier
+{
+    __weak typeof(self) weakSelf = self;
+
+    if ([specifier.specifierDict[@"Key"] isEqual: @"forceMediaLibraryRescan"]) {
+        UIAlertController *alert = [UIAlertController
+                                    alertControllerWithTitle:NSLocalizedString(@"FORCE_RESCAN_TITLE", "")
+                                                     message:NSLocalizedString(@"FORCE_RESCAN_MESSAGE", "")
+                                              preferredStyle:UIAlertControllerStyleAlert];
+
+        UIAlertAction* rescanAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_RESCAN", "")
+                                                                style:UIAlertActionStyleDestructive
+                                                              handler:^(UIAlertAction * action) {
+            __strong typeof(weakSelf) strongSelf = weakSelf;
+            dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
+                [strongSelf->_medialibraryService forceRescan];
+            });
+        }];
+        UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"BUTTON_CANCEL", "")
+                                                               style:UIAlertActionStyleCancel
+                                                             handler:nil];
+
+        [alert addAction:cancelAction];
+        [alert addAction:rescanAction];
+        [self presentViewController:alert animated:YES completion:nil];
+    }
+}
+
 @end

+ 4 - 0
Sources/VLCSettingsTableViewCell.swift

@@ -35,6 +35,8 @@ class VLCSettingsTableViewCell: UITableViewCell {
             accessoryType = .disclosureIndicator
         case kIASKPSMultiValueSpecifier:
             accessoryType = .none
+        case kIASKButtonSpecifier:
+            accessoryType = .none
         default:
             assertionFailure("\(reuseIdentifier) has not been defined for VLCSettingsTableViewCell")
         }
@@ -57,6 +59,8 @@ class VLCSettingsTableViewCell: UITableViewCell {
             configureMultiValue(specifier, settingsValue)
         case kIASKOpenURLSpecifier:
             break
+        case kIASKButtonSpecifier:
+            break
         default:
             assertionFailure("\(specifier.type() ?? "nil") has not been defined for VLCSettingsTableViewCell")
         }