diff --git a/Podfile.lock b/Podfile.lock index 30aed5be3efa84440b4e42bafe60d57e1402dda8..a195ec749285096e4ace55b112e5b5d8981b130e 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -205,4 +205,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 65a7fa9ee482022fade614219df0522c6399aafe -COCOAPODS: 1.15.2 +COCOAPODS: 1.16.2 diff --git a/Resources/iOS/Settings.bundle/en.lproj/Root.strings b/Resources/iOS/Settings.bundle/en.lproj/Root.strings index 533c90bd7d489466e65cc99270b30deca5611c96..3847352cd749a95df8e93f199f913af9f8ae43f1 100644 --- a/Resources/iOS/Settings.bundle/en.lproj/Root.strings +++ b/Resources/iOS/Settings.bundle/en.lproj/Root.strings @@ -171,3 +171,6 @@ "SETTINGS_RESET" = "Reset the settings"; "SETTINGS_RESET_TITLE" = "Reset"; + +"SETTINGS_PARENTAL_CONTROL_TOGGLE" = "Parental control"; +"SETTINGS_PARENTAL_CONTROL_SUBTITLE" = "When activated, files cannot be deleted or playlists modified without entering the pin"; diff --git a/Resources/iOS/Settings.bundle/pt-BR.lproj/Root.strings b/Resources/iOS/Settings.bundle/pt-BR.lproj/Root.strings index 38832c02ce9be7bc71aa79f05a889d12578ace9e..20b42e7220179e85afce410df6c641bfd0b3c074 100644 Binary files a/Resources/iOS/Settings.bundle/pt-BR.lproj/Root.strings and b/Resources/iOS/Settings.bundle/pt-BR.lproj/Root.strings differ diff --git a/Sources/Headers/VLCConstants.h b/Sources/Headers/VLCConstants.h index c5d22a5b154c56bff82141ad42060c657cdc2bda..ebf2acc4d4c12c0a206398f298491ee3fd675d1f 100644 --- a/Sources/Headers/VLCConstants.h +++ b/Sources/Headers/VLCConstants.h @@ -185,6 +185,8 @@ #define kVLCDonationAnonymousCustomerID @"kVLCDonationAnonymousCustomerID" +#define kVLCSettingParentalControl @"kVLCSettingParentalControl" + /* LEGACY KEYS, DO NOT USE IN NEW CODE */ #define kVLCFTPServer @"ftp-server" #define kVLCFTPLogin @"ftp-login" diff --git a/Sources/Media Library/Editing/EditActions.swift b/Sources/Media Library/Editing/EditActions.swift index 5fd1b8e53550c8804b89baaedcd018c48771ee7a..cd4b999593c266576702c969079b414bb7deb0c1 100644 --- a/Sources/Media Library/Editing/EditActions.swift +++ b/Sources/Media Library/Editing/EditActions.swift @@ -8,6 +8,8 @@ * Refer to the COPYING file of the official project for license. *****************************************************************************/ +import LocalAuthentication + enum completionState { case inProgress case success @@ -204,9 +206,21 @@ extension EditActions { let deleteButton = VLCAlertButton(title: NSLocalizedString("BUTTON_DELETE", comment: ""), style: .destructive, action: { [unowned self] action in - self.model.anyDelete(self.objects) - self.objects.removeAll() - self.completion?(.success) + if UserDefaults.standard.bool(forKey: kVLCSettingParentalControl) { + self.authenticateUser { success in + if success { + self.model.anyDelete(self.objects) + self.objects.removeAll() + self.completion?(.success) + } else { + self.completion?(.fail) + } + } + } else { + self.model.anyDelete(self.objects) + self.objects.removeAll() + self.completion?(.success) + } }) VLCAlertViewController.alertViewManager(title: title, @@ -349,6 +363,17 @@ private extension EditActions { } return fileURLs } + + private func authenticateUser(completion: @escaping (Bool) -> Void) { + let coordinator = KeychainCoordinator.passcodeService + coordinator.validateSecret( + allowBiometricAuthentication: false, // no faceid for now + isCancellable: true + ) { success in + completion(success) + } + } + // MARK: Media Groups diff --git a/Sources/Settings/Model/SettingsSection.swift b/Sources/Settings/Model/SettingsSection.swift index 5897ba3c261327b615fc54b91157c47ec1c5e602..a403d8261cb5be108cbecbb6c4ee3784a043eaac 100644 --- a/Sources/Settings/Model/SettingsSection.swift +++ b/Sources/Settings/Model/SettingsSection.swift @@ -175,6 +175,12 @@ enum MainOptions { subtitle: Localizer.getSubtitle(for: k), action: .showActionSheet(title: "SETTINGS_DARKTHEME", preferenceKey: k, hasInfo: false)) } + + static var parentalControl: SettingsItem { + .toggle(title: "SETTINGS_PARENTAL_CONTROL_TOGGLE", + subtitle: "SETTINGS_PARENTAL_CONTROL_SUBTITLE", + preferenceKey: kVLCSettingParentalControl) + } static func section() -> SettingsSection? { var items = [privacy] @@ -182,6 +188,7 @@ enum MainOptions { // visionOS uses a standard system appearance and doesn't have light/dark mode. items.append(appearance) #endif + items.append(parentalControl) return .init(title: nil, items: items) } }