Prechádzať zdrojové kódy

3.6.13(6)将相册,从第三方切换到原生

100Years 1 týždeň pred
rodič
commit
efdffa2861

+ 6 - 2
TSLiveWallpaper.xcodeproj/project.pbxproj

@@ -101,6 +101,7 @@
 		A8A2F0D62E3B44C800E7B86B /* TSVideoPlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A2F0D52E3B44C800E7B86B /* TSVideoPlayer.swift */; };
 		A8A2F0D92E3B47AE00E7B86B /* aiList SendRose Banner.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = A8A2F0D72E3B47AE00E7B86B /* aiList SendRose Banner.mp4 */; };
 		A8A2F0DA2E3B47AE00E7B86B /* New Smile.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = A8A2F0D82E3B47AE00E7B86B /* New Smile.mp4 */; };
+		A8A2F0DE2E3C959F00E7B86B /* TSHXPhotoPickerManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8A2F0DD2E3C959600E7B86B /* TSHXPhotoPickerManager.swift */; };
 		A8C4C0EF2D27BFF7003C46FC /* TSNetworkTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8C4C0EE2D27BFEA003C46FC /* TSNetworkTool.swift */; };
 		A8E56BF62D1520EC003C54AF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8E56BEC2D1520EC003C54AF /* AppDelegate.swift */; };
 		A8E56BF92D1520EC003C54AF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A8E56BED2D1520EC003C54AF /* Assets.xcassets */; };
@@ -293,6 +294,7 @@
 		A8A2F0D52E3B44C800E7B86B /* TSVideoPlayer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSVideoPlayer.swift; sourceTree = "<group>"; };
 		A8A2F0D72E3B47AE00E7B86B /* aiList SendRose Banner.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "aiList SendRose Banner.mp4"; sourceTree = "<group>"; };
 		A8A2F0D82E3B47AE00E7B86B /* New Smile.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; path = "New Smile.mp4"; sourceTree = "<group>"; };
+		A8A2F0DD2E3C959600E7B86B /* TSHXPhotoPickerManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSHXPhotoPickerManager.swift; sourceTree = "<group>"; };
 		A8C4C0A92D242204003C46FC /* Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bridging-Header.h"; sourceTree = "<group>"; };
 		A8C4C0EE2D27BFEA003C46FC /* TSNetworkTool.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TSNetworkTool.swift; sourceTree = "<group>"; };
 		A8E56BD42D1520DD003C54AF /* TSLiveWallpaper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TSLiveWallpaper.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -766,6 +768,7 @@
 			children = (
 				A8EE84452E33931000CA04F0 /* KFImageView.swift */,
 				A86857A62DF9204B0089D222 /* TSPhotoPickerManager.swift */,
+				A8A2F0DD2E3C959600E7B86B /* TSHXPhotoPickerManager.swift */,
 			);
 			path = TSPhotoPickerManager;
 			sourceTree = "<group>";
@@ -1287,6 +1290,7 @@
 				A83F28892E162343009A4975 /* TSAIListDataVM.swift in Sources */,
 				A8EB1A3E2E2F879C001F58D7 /* TSAIListStyleMoreVC.swift in Sources */,
 				A83F288D2E162B19009A4975 /* TSAILIstFullCardCell.swift in Sources */,
+				A8A2F0DE2E3C959F00E7B86B /* TSHXPhotoPickerManager.swift in Sources */,
 				A8F9F2F42E372C35007FE237 /* TSAIExpandStyleView.swift in Sources */,
 				A8EB1A322E2F716A001F58D7 /* TSImagesComparisonView.swift in Sources */,
 				A8F76C4D2D3747B400AA6E93 /* TSPurchaseVC.swift in Sources */,
@@ -1465,7 +1469,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 5;
+				CURRENT_PROJECT_VERSION = 6;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_APP_SANDBOX = NO;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -1506,7 +1510,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 5;
+				CURRENT_PROJECT_VERSION = 6;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_APP_SANDBOX = NO;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;

+ 2 - 2
TSLiveWallpaper/Business/TSAIListVC/TSAIListHistoryVC/View/TSGennerateCellView.swift

@@ -87,10 +87,10 @@ class TSGennerateCellView: TSBaseView {
         refreshBtn.isHidden = true
         isCanClick = false
         let progressInt = Int(progress*100)
-        infoLabel.text = "Processing you photo".localized + "..." + "\n\n" + kPercentlocalized(progressInt)
+        infoLabel.text = "Processing your photo".localized + "..." + "\n\n" + kPercentlocalized(progressInt)
         
         if kIsRTL {
-            infoLabel.text = "Processing you photo".localized + "..." + "\n\n" + "\(progressInt)%"
+            infoLabel.text = "Processing your photo".localized + "..." + "\n\n" + "\(progressInt)%"
         }
 
         infoLabel.textColor = .themeColor

+ 3 - 3
TSLiveWallpaper/Common/Purchase/TSPurchaseManager.swift

@@ -82,9 +82,9 @@ public class PurchaseManager: NSObject {
     }
 
     @objc public var isVip: Bool {
-//        #if DEBUG
-//        return true
-//        #endif
+        #if DEBUG
+        return true
+        #endif
         guard let expiresDate = expiredDate else {
             return false
         }

+ 368 - 0
TSLiveWallpaper/Common/ViewTool/TSPhotoPickerManager/TSHXPhotoPickerManager.swift

@@ -0,0 +1,368 @@
+//
+//  TSHXPhotoPickerManager.swift
+//  TSLiveWallpaper
+//
+//  Created by 100Years on 2025/7/31.
+//
+
+
+//import UIKit
+//import PhotosUI
+//import HXPhotoPicker
+//
+//class TSPhotoPickerManager: NSObject{
+//
+//    lazy var cropSize: EditorConfiguration.ToolsView.Options = {
+//        let cropSize = EditorConfiguration.ToolsView.Options(
+//            imageType: HX.ImageResource.shared.editor.tools.cropSize,
+//            type: .cropSize
+//        )
+//        return cropSize
+//    }()
+//    
+//    lazy var aspectRatios: [EditorRatioToolConfig] = {
+//        let aspectRatios:[EditorRatioToolConfig] = [
+//            .init(title: .localized("原始比例"), ratio: .init(width: -1, height: -1)),
+//            .init(title: .localized("自由格式"), ratio: .zero),
+//            .init(title: .localized("正方形"), ratio: .init(width: 1, height: 1)),
+//            .init(title: .custom("9:16"), ratio: .init(width: 9, height: 16)),
+//            .init(title: .custom("16:9"), ratio: .init(width: 16, height: 9)),
+//            .init(title: .custom("3:4"), ratio: .init(width: 3, height: 4)),
+//            .init(title: .custom("4:3"), ratio: .init(width: 4, height: 3)),
+//            .init(title: .custom("2:3"), ratio: .init(width: 2, height: 3)),
+//            .init(title: .custom("3:2"), ratio: .init(width: 3, height: 2))
+//        ]
+//        return aspectRatios
+//    }()
+//    
+//    var picker: PhotoPickerController?
+//    var multipleConfig: PickerConfiguration{
+//        var config = PickerConfiguration()
+//        config.appearanceStyle = .dark
+//        config.modalPresentationStyle = .overFullScreen
+//        config.themeColor = .themeColor
+//        config.selectOptions = .photo
+//        config.selectMode = .multiple
+//        config.maximumSelectedCount = 2
+//        config.isSelectedOriginal = true
+//        config.photoList.sort = .desc
+//        config.photoList.finishSelectionAfterTakingPhoto = false
+//        config.photoList.isSaveSystemAlbum = true
+//        config.isCacheCameraAlbum = false
+//        config.navigationTitleColor = .white
+//        config.navigationTitleDarkColor = .white
+//        config.navigationTintColor = .white
+//        config.navigationDarkTintColor = .white
+//        config.albumList.albumNameColor = .white
+//        config.albumList.albumNameDarkColor = .white
+//
+//        config.albumShowMode = .normal
+//        config.photoList.takePictureCompletionToSelected = true
+//        
+//        config.previewView.backgroundColor = .black
+//        config.previewView.bottomView.isHiddenOriginalButton = true
+//        
+//        config.photoList.bottomView.isHiddenOriginalButton = true
+//        config.navigationBarStyle = .black
+//    
+////        config.photoSelectionTapAction = .quickSelect
+////        config.photoList.bottomView.isHiddenPreviewButton = true
+////        config.photoList.bottomView.isShowSelectedView = false
+//        
+//        config.photoSelectionTapAction = .preview
+//        config.photoList.bottomView.isHiddenPreviewButton = false
+//        config.photoList.bottomView.isShowSelectedView = true
+//        config.photoList.previewStyle = .push
+//        
+//        config.editor.toolsView = .init(toolOptions: [cropSize])
+//        config.editor.cropSize.aspectRatios = aspectRatios
+//        
+//        
+////        var cameraConfig = SystemCameraConfiguration()
+////        cameraConfig.allowsEditing = false
+////        config.photoList.cameraType = .system(cameraConfig)
+//        
+//        var customCameraConfig = CameraConfiguration()
+//        customCameraConfig.isSaveSystemAlbum = true
+//        customCameraConfig.sessionPreset = .hd1920x1080
+//        customCameraConfig.editor.toolsView = .init(toolOptions: [cropSize])
+//        customCameraConfig.editor.cropSize.aspectRatios = aspectRatios
+//        config.photoList.cameraType = .custom(customCameraConfig)
+//    
+//
+//        config.languageType = LanguageManager.shared.currentLanguage.languageType
+//        config.customLanguages = [CustomLanguage(language: "it", bundle: Bundle(path: Bundle.main.path(forResource: "it", ofType: "lproj")!)!)]
+//        config.photoList.isShowFilterItem = false
+//        
+//        config.textManager.picker.albumCameraRollTitle = .localized("HXAlbumCameraRoll")
+//        config.textManager.picker.photoList.emptyTitle = .localized("没有照片")
+//        config.textManager.picker.photoList.emptySubTitle = .localized("你可以使用相机拍些照片")
+//        
+//        return config
+//    }
+//    
+//
+//    // MARK: - Properties
+//    private weak var viewController: UIViewController?
+//    private var completionHandler: (([UIImage]) -> Void)?
+//    private var maxSelected:Int = 1
+//    // MARK: - Initializers
+//    init(viewController: UIViewController) {
+//        self.viewController = viewController
+//    }
+//    
+//    // MARK: - Public Methods
+//    /// 打开照片选择器,单选一张照片
+//    func pickPhoto(maxSelected:Int = 1,completion: @escaping ([UIImage]) -> Void) {
+//        self.completionHandler = completion
+//        self.maxSelected = maxSelected
+//        
+//        var config = multipleConfig
+//        config.maximumSelectedCount = maxSelected
+//
+//        
+//        checkPhotoLibraryPermission { [weak self] authorized in
+//            guard let self = self else { return }
+//            if authorized {
+//                let picker = PhotoPickerController(splitPicker: config)
+//                picker.pickerDelegate = self
+//                picker.autoDismiss = false
+//                picker.modalTransitionStyle = .coverVertical
+//                viewController?.present(picker, animated: true, completion: nil)
+//                picker.reloadAlbumData()
+//                self.picker = picker
+//                
+//            } else {
+//                self.showPermissionAlert()
+//            }
+//        }
+//    }
+//    
+//    var cameraController:CameraController?
+//    func pickCameraPhoto(maxSelected:Int = 1,completion: @escaping ([UIImage]) -> Void) {
+//        self.completionHandler = completion
+//        checkVideoAuthorization { [weak self] authorized in
+//            guard let self = self else { return }
+//            if authorized {
+//                var customCameraConfig = CameraConfiguration()
+//                customCameraConfig.isSaveSystemAlbum = true
+//                customCameraConfig.sessionPreset = .hd1920x1080
+//                customCameraConfig.editor.toolsView = .init(toolOptions: [cropSize])
+//                customCameraConfig.editor.cropSize.aspectRatios = aspectRatios
+//                customCameraConfig.languageType = LanguageManager.shared.currentLanguage.languageType
+//                customCameraConfig.customLanguages = [CustomLanguage(language: "it", bundle: Bundle(path: Bundle.main.path(forResource: "it", ofType: "lproj")!)!)]
+//                customCameraConfig.modalPresentationStyle = .overFullScreen
+//                let cameraController = CameraController(config: customCameraConfig, type: .photo,delegate: self)
+//                viewController?.present(cameraController, animated: true, completion: nil)
+//                self.cameraController = cameraController
+//            } else {
+//                self.showCameraPermissionAlert()
+//            }
+//        }
+//    }
+//    
+//    
+//    //选择本地图片
+//    func pickLoactionPhoto(maxSelected:Int = 1,completion: @escaping ([UIImage]) -> Void) {
+//        
+//        self.completionHandler = completion
+//        self.maxSelected = maxSelected
+//        
+//        PickerConfiguration.imageViewProtocol = KFImageView.self
+//        
+//        var config = multipleConfig
+//        config.maximumSelectedCount = maxSelected
+//        config.languageType = LanguageManager.shared.currentLanguage.languageType
+//        config.customLanguages = [CustomLanguage(language: "it", bundle: Bundle(path: Bundle.main.path(forResource: "it", ofType: "lproj")!)!)]
+//        config.selectOptions = []
+//        config.photoList.allowAddCamera = false
+//        
+//        config.textManager.picker.albumCameraRollTitle = .custom("Used Photo".localized)
+//        config.textManager.picker.photoList.emptyTitle = .custom("")
+//        config.textManager.picker.photoList.emptySubTitle = .custom("No used photo. Select from Photos or take one to continue.".localized)
+//        config.allowLoadPhotoLibrary = false
+//  
+//        var photoAsset:[PhotoAsset] = []
+//        let allKeys = TSDBKeyManager.getAllKeys()
+//        for item in allKeys {
+//            let key = item.key
+//            let url = URL(string:key)
+//            photoAsset.append( PhotoAsset(
+//                networkImageAsset:
+//                    NetworkImageAsset(
+//                        thumbnailURL: url,
+//                        originalURL: url,
+//                        thumbailCacheKey: key,
+//                        originalCacheKey: key
+//                    )
+//            ))
+//        }
+//
+//        let picker = PhotoPickerController(splitPicker: config)
+//        picker.pickerDelegate = self
+//        picker.autoDismiss = false
+//        picker.localAssetArray = photoAsset
+//        picker.modalTransitionStyle = .coverVertical
+//        viewController?.present(picker, animated: true, completion: nil)
+//        self.picker = picker
+//
+//    }
+//    
+//
+//    
+//    
+//    
+//    // MARK: - Private Methods
+//    /// 检查相册权限
+//    private func checkPhotoLibraryPermission(completion: @escaping (Bool) -> Void) {
+//        let status = PHPhotoLibrary.authorizationStatus()
+//        
+//        DispatchQueue.main.async {
+//            switch status {
+//            case .authorized:
+//                completion(true)
+//            case .notDetermined:
+//                PHPhotoLibrary.requestAuthorization { newStatus in
+//                    DispatchQueue.main.async {
+//                        completion(newStatus == .authorized)
+//                    }
+//                }
+//            default:
+//                DispatchQueue.main.async {
+//                    completion(false)
+//                }
+//            }
+//        }
+//    }
+//    
+//    
+//    /// 检查相机权限状态
+//       func checkVideoAuthorization(completion: @escaping (Bool) -> Void) {
+//           let status = AVCaptureDevice.authorizationStatus(for: .video)
+//           DispatchQueue.main.async {
+//               switch status {
+//               case .authorized:
+//                    completion(true)
+//               case .notDetermined:
+//                   AVCaptureDevice.requestAccess(for: .video) { granted in
+//                       DispatchQueue.main.async {
+//                           completion(granted)
+//                       }
+//                   }
+//               case .denied, .restricted:
+//                   completion(false)
+//               @unknown default:
+//                   completion(false)
+//               }
+//           }
+//       }
+//
+//    /// 显示权限提示
+//    private func showPermissionAlert() {
+//        let alert = UIAlertController(
+//            title: "No photos permission".localized,
+//            message: "Please enable photo permission in settings to select photos".localized,
+//            preferredStyle: .alert
+//        )
+//        alert.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil))
+//        alert.addAction(UIAlertAction(title: "Go to Settings".localized, style: .default) { _ in
+//            if let url = URL(string: UIApplication.openSettingsURLString) {
+//                UIApplication.shared.open(url, options: [:], completionHandler: nil)
+//            }
+//        })
+//        viewController?.present(alert, animated: true, completion: nil)
+//    }
+//    
+//    
+//    private func showCameraPermissionAlert() {
+//        let alert = UIAlertController(
+//            title: "No camera permission".localized,
+//            message: "Please enable camera permission in settings to select camera".localized,
+//            preferredStyle: .alert
+//        )
+//        alert.addAction(UIAlertAction(title: "Cancel".localized, style: .cancel, handler: nil))
+//        alert.addAction(UIAlertAction(title: "Go to Settings".localized, style: .default) { _ in
+//            if let url = URL(string: UIApplication.openSettingsURLString) {
+//                UIApplication.shared.open(url, options: [:], completionHandler: nil)
+//            }
+//        })
+//        viewController?.present(alert, animated: true, completion: nil)
+//    }
+//    
+//    deinit {
+//        debugPrint("♻️♻️♻️ TSPhotoPickerManager -> TSPhotoPickerManager deinit ♻️♻️♻️")
+//    }
+//    
+//    func dismissPageVC(){
+//        self.picker?.view.isHidden = true
+//        self.picker?.dismiss(animated: true)
+//        self.picker = nil
+//        
+//        cameraController?.dismiss(animated: true)
+//        cameraController = nil
+//    }
+//}
+//
+//extension TSPhotoPickerManager: PhotoPickerControllerDelegate {
+//    func pickerController(_ pickerController: PhotoPickerController, didFinishSelection result: PickerResult) {
+//        result.getImage(compressionScale: 1.0) { images in
+//            self.completionHandler?(images)
+//            pickerController.dismiss(animated: true, completion: nil)
+//            for image in images {
+//                if let imageKey = image.uniqueIdentifier() {
+//                    TSDBKeyManager.addOrUpdateKey(imageKey)
+//                    TSImageStoreTool.storeImage(image: image, urlString: imageKey)
+//                }
+//            }
+//            
+//            NotificationCenter.default.post(name: .kPhotoPickerCompleted, object: nil, userInfo: nil)
+//            
+//        }
+//    }
+//    
+//    func pickerController(didCancel pickerController: PhotoPickerController) {
+//        pickerController.dismiss(animated: true, completion: nil)
+//    }
+//}
+//
+//
+//extension TSPhotoPickerManager : CameraControllerDelegate {
+//    func cameraController(_ cameraController: HXPhotoPicker.CameraController, didFinishWithResult result: HXPhotoPicker.CameraController.Result, phAsset: PHAsset?, location: CLLocation?) {
+//        switch result {
+//        case .image(let image):
+//            self.completionHandler?([image])
+//            cameraController.dismiss(animated: true, completion: nil)
+//            if let imageKey = image.uniqueIdentifier() {
+//                TSDBKeyManager.addOrUpdateKey(imageKey)
+//                TSImageStoreTool.storeImage(image: image, urlString: imageKey)
+//            }
+//            NotificationCenter.default.post(name: .kPhotoPickerCompleted, object: nil, userInfo: nil)
+//            
+//        default:
+//            cameraController.dismiss(animated: true, completion: nil)
+//        }
+//    }
+//    
+//    func cameraController(didCancel cameraController: HXPhotoPicker.CameraController) {
+//        cameraController.dismiss(animated: true, completion: nil)
+//    }
+//}
+//extension Notification.Name {
+//    static let kPhotoPickerCompleted = Notification.Name("kPhotoPickerCompleted") //选择照片完成
+//}
+//
+//
+//import Foundation
+//import CommonCrypto
+//
+//extension UIImage {
+//    func uniqueIdentifier() -> String? {
+//        guard let imageData = self.jpegData(compressionQuality: 0.1) else { return nil }
+//        
+//        var digest = [UInt8](repeating: 0, count: Int(CC_SHA256_DIGEST_LENGTH))
+//        imageData.withUnsafeBytes {
+//            _ = CC_SHA256($0.baseAddress, CC_LONG(imageData.count), &digest)
+//        }
+//        return digest.map { String(format: "%02hhx", $0) }.joined()
+//    }
+//}

+ 88 - 45
TSLiveWallpaper/Common/ViewTool/TSPhotoPickerManager/TSPhotoPickerManager.swift

@@ -57,50 +57,49 @@ class TSPhotoPickerManager: NSObject{
 
         config.albumShowMode = .normal
         config.photoList.takePictureCompletionToSelected = true
-        
+
         config.previewView.backgroundColor = .black
         config.previewView.bottomView.isHiddenOriginalButton = true
-        
+
         config.photoList.bottomView.isHiddenOriginalButton = true
         config.navigationBarStyle = .black
-    
+
 //        config.photoSelectionTapAction = .quickSelect
 //        config.photoList.bottomView.isHiddenPreviewButton = true
 //        config.photoList.bottomView.isShowSelectedView = false
-        
+
         config.photoSelectionTapAction = .preview
         config.photoList.bottomView.isHiddenPreviewButton = false
         config.photoList.bottomView.isShowSelectedView = true
         config.photoList.previewStyle = .push
-        
+
         config.editor.toolsView = .init(toolOptions: [cropSize])
         config.editor.cropSize.aspectRatios = aspectRatios
-        
-        
+
+
 //        var cameraConfig = SystemCameraConfiguration()
 //        cameraConfig.allowsEditing = false
 //        config.photoList.cameraType = .system(cameraConfig)
-        
+
         var customCameraConfig = CameraConfiguration()
         customCameraConfig.isSaveSystemAlbum = true
         customCameraConfig.sessionPreset = .hd1920x1080
         customCameraConfig.editor.toolsView = .init(toolOptions: [cropSize])
         customCameraConfig.editor.cropSize.aspectRatios = aspectRatios
         config.photoList.cameraType = .custom(customCameraConfig)
-    
+
 
         config.languageType = LanguageManager.shared.currentLanguage.languageType
         config.customLanguages = [CustomLanguage(language: "it", bundle: Bundle(path: Bundle.main.path(forResource: "it", ofType: "lproj")!)!)]
         config.photoList.isShowFilterItem = false
-        
+
         config.textManager.picker.albumCameraRollTitle = .localized("HXAlbumCameraRoll")
         config.textManager.picker.photoList.emptyTitle = .localized("没有照片")
         config.textManager.picker.photoList.emptySubTitle = .localized("你可以使用相机拍些照片")
-        
+
         return config
     }
     
-
     // MARK: - Properties
     private weak var viewController: UIViewController?
     private var completionHandler: (([UIImage]) -> Void)?
@@ -115,28 +114,42 @@ class TSPhotoPickerManager: NSObject{
     func pickPhoto(maxSelected:Int = 1,completion: @escaping ([UIImage]) -> Void) {
         self.completionHandler = completion
         self.maxSelected = maxSelected
-        
-        var config = multipleConfig
-        config.maximumSelectedCount = maxSelected
-
-        
         checkPhotoLibraryPermission { [weak self] authorized in
             guard let self = self else { return }
             if authorized {
-                let picker = PhotoPickerController(splitPicker: config)
-                picker.pickerDelegate = self
-                picker.autoDismiss = false
-                picker.modalTransitionStyle = .coverVertical
-                viewController?.present(picker, animated: true, completion: nil)
-                picker.reloadAlbumData()
-                self.picker = picker
-                
+//                let picker = PhotoPickerController(splitPicker: config)
+//                picker.pickerDelegate = self
+//                picker.autoDismiss = false
+//                picker.modalTransitionStyle = .coverVertical
+//                viewController?.present(picker, animated: true, completion: nil)
+//                picker.reloadAlbumData()
+//                self.picker = picker
+                openPhotoPicker()//系统的相册
             } else {
                 self.showPermissionAlert()
             }
         }
     }
     
+    /// 打开照片选择器
+    private var imagePicker:UIImagePickerController?
+    private func openPhotoPicker() {
+        TSToastShared.showLoading(containerView: viewController?.view)
+        let imagePicker = UIImagePickerController()
+        imagePicker.sourceType = .photoLibrary
+        imagePicker.delegate = self
+        imagePicker.mediaTypes = ["public.image"] // 只选择照片
+//        imagePicker.modalPresentationStyle = .custom
+//        imagePicker.modalTransitionStyle = .crossDissolve
+        if #available(iOS 13.0, *) {
+            imagePicker.overrideUserInterfaceStyle = .dark
+        }
+        viewController?.present(imagePicker, animated: true) {
+            TSToastShared.hideLoading()
+        }
+        self.imagePicker = imagePicker
+    }
+    
     var cameraController:CameraController?
     func pickCameraPhoto(maxSelected:Int = 1,completion: @escaping ([UIImage]) -> Void) {
         self.completionHandler = completion
@@ -208,8 +221,7 @@ class TSPhotoPickerManager: NSObject{
     }
     
 
-    
-    
+
     
     // MARK: - Private Methods
     /// 检查相册权限
@@ -296,26 +308,42 @@ class TSPhotoPickerManager: NSObject{
         self.picker?.view.isHidden = true
         self.picker?.dismiss(animated: true)
         self.picker = nil
+   
+        imagePicker?.dismiss(animated: true, completion: nil)
+        imagePicker = nil
         
         cameraController?.dismiss(animated: true)
         cameraController = nil
     }
 }
-
+extension TSPhotoPickerManager {
+    func saveImagesToUsed(images:[UIImage]){
+        //保存图片到已使用中
+        for image in images {
+            if let imageKey = image.uniqueIdentifier() {
+                TSDBKeyManager.addOrUpdateKey(imageKey)
+                TSImageStoreTool.storeImage(image: image, urlString: imageKey)
+            }
+        }
+        NotificationCenter.default.post(name: .kPhotoPickerCompleted, object: nil, userInfo: nil)
+    }
+    
+    func saveImageToUsed(image:UIImage){
+        //保存图片到已使用中
+        if let imageKey = image.uniqueIdentifier() {
+            TSDBKeyManager.addOrUpdateKey(imageKey)
+            TSImageStoreTool.storeImage(image: image, urlString: imageKey)
+        }
+        NotificationCenter.default.post(name: .kPhotoPickerCompleted, object: nil, userInfo: nil)
+    }
+    
+}
 extension TSPhotoPickerManager: PhotoPickerControllerDelegate {
     func pickerController(_ pickerController: PhotoPickerController, didFinishSelection result: PickerResult) {
-        result.getImage(compressionScale: 1.0) { images in
-            self.completionHandler?(images)
+        result.getImage(compressionScale: 1.0) { [weak self] images in
+            self?.completionHandler?(images)
             pickerController.dismiss(animated: true, completion: nil)
-            for image in images {
-                if let imageKey = image.uniqueIdentifier() {
-                    TSDBKeyManager.addOrUpdateKey(imageKey)
-                    TSImageStoreTool.storeImage(image: image, urlString: imageKey)
-                }
-            }
-            
-            NotificationCenter.default.post(name: .kPhotoPickerCompleted, object: nil, userInfo: nil)
-            
+            self?.saveImagesToUsed(images: images)
         }
     }
     
@@ -331,11 +359,8 @@ extension TSPhotoPickerManager : CameraControllerDelegate {
         case .image(let image):
             self.completionHandler?([image])
             cameraController.dismiss(animated: true, completion: nil)
-            if let imageKey = image.uniqueIdentifier() {
-                TSDBKeyManager.addOrUpdateKey(imageKey)
-                TSImageStoreTool.storeImage(image: image, urlString: imageKey)
-            }
-            NotificationCenter.default.post(name: .kPhotoPickerCompleted, object: nil, userInfo: nil)
+            
+            saveImageToUsed(image: image)
             
         default:
             cameraController.dismiss(animated: true, completion: nil)
@@ -346,11 +371,29 @@ extension TSPhotoPickerManager : CameraControllerDelegate {
         cameraController.dismiss(animated: true, completion: nil)
     }
 }
+
+// MARK: - UIImagePickerControllerDelegate & UINavigationControllerDelegate (iOS 14 以下)
+extension TSPhotoPickerManager: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
+    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
+        if let image = info[.originalImage] as? UIImage {
+            self.completionHandler?([image])
+            saveImageToUsed(image: image)
+            
+        } else {
+            self.completionHandler?([])
+        }
+    }
+    
+    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
+        picker.dismiss(animated: true, completion: nil)
+    }
+}
+
+
 extension Notification.Name {
     static let kPhotoPickerCompleted = Notification.Name("kPhotoPickerCompleted") //选择照片完成
 }
 
-
 import Foundation
 import CommonCrypto
 

+ 1 - 1
TSLiveWallpaper/ar.lproj/Localizable.strings

@@ -115,7 +115,7 @@
 "Example" = "مثال";
 "Limited Time Discount" = "خصم لفترة محدودة";
 "This task has expired" = "انتهت صلاحية هذه المهمة";
-"Processing you photo" = "معالجة صورتك";
+"Processing your photo" = "معالجة صورتك";
 "Enlighten Tips" = "نصائح التنوير";
 "Payment Failed" = "فشل الدفع";
 "The subscription was canceled" = "تم إلغاء الاشتراك";

+ 1 - 1
TSLiveWallpaper/de.lproj/Localizable.strings

@@ -32,7 +32,7 @@
 "Payment Failed" = "Zahlung fehlgeschlagen";
 "The subscription was canceled" = "Das Abonnement wurde gekündigt";
 "This task has expired" = "Diese Aufgabe ist abgelaufen";
-"Processing you photo" = "Ihr Foto wird verarbeitet";
+"Processing your photo" = "Ihr Foto wird verarbeitet";
 "Enlighten Tips" = "Enlighten-Tipps";
 "Verify receipt failed" = "Bestätigung der Quittung fehlgeschlagen";
 "Purchasing now" = "Jetzt kaufen";

+ 1 - 1
TSLiveWallpaper/en.lproj/Localizable.strings

@@ -114,7 +114,7 @@
 "Example" = "Example";
 "Limited Time Discount" = "Limited Time Discount";
 "This task has expired" = "This task has expired";
-"Processing you photo" = "Processing you photo";
+"Processing your photo" = "Processing your photo";
 "Enlighten Tips" = "Enlighten Tips";
 "Payment Failed" = "Payment Failed";
 "The subscription was canceled" = "The subscription was canceled";

+ 1 - 1
TSLiveWallpaper/es.lproj/Localizable.strings

@@ -115,7 +115,7 @@
 "Example" = "Ejemplo";
 "Limited Time Discount" = "Oferta por Tiempo Limitado";
 "This task has expired" = "Esta tarea ha expirado";
-"Processing you photo" = "Procesando tu foto";
+"Processing your photo" = "Procesando tu foto";
 "Enlighten Tips" = "Consejos para iluminar";
 "Payment Failed" = "Pago fallido";
 "The subscription was canceled" = "La suscripción fue cancelada";

+ 1 - 1
TSLiveWallpaper/fr.lproj/Localizable.strings

@@ -32,7 +32,7 @@
 "Payment Failed" = "Paiement échoué";
 "The subscription was canceled" = "L'abonnement a été annulé";
 "This task has expired" = "Cette tâche a expiré";
-"Processing you photo" = "Traitement de votre photo";
+"Processing your photo" = "Traitement de votre photo";
 "Enlighten Tips" = "Conseils d'éclairage";
 "Verify receipt failed" = "La vérification du reçu a échoué";
 "Purchasing now" = "Acheter maintenant";

+ 1 - 1
TSLiveWallpaper/it.lproj/Localizable.strings

@@ -32,7 +32,7 @@
 "Payment Failed" = "Pagamento non riuscito";
 "The subscription was canceled" = "L'abbonamento è stato annullato";
 "This task has expired" = "Questo compito è scaduto";
-"Processing you photo" = "Elaborazione della tua foto";
+"Processing your photo" = "Elaborazione della tua foto";
 "Enlighten Tips" = "Suggerimenti illuminanti";
 "Verify receipt failed" = "Verifica ricevuta non riuscita";
 "Purchasing now" = "Acquista ora";

+ 1 - 1
TSLiveWallpaper/ja.lproj/Localizable.strings

@@ -25,7 +25,7 @@
 "Payment Failed" = "支払い失敗";
 "The subscription was canceled" = "サブスクリプションがキャンセルされました";
 "This task has expired" = "このタスクは期限切れです";
-"Processing you photo" = "写真を処理中です";
+"Processing your photo" = "写真を処理中です";
 "Enlighten Tips" = "Enlighten Tips";
 "Verify receipt failed" = "受領確認に失敗しました";
 "Purchasing now" = "購入中です";

+ 1 - 1
TSLiveWallpaper/ko.lproj/Localizable.strings

@@ -25,7 +25,7 @@
 "Payment Failed" = "결제 실패";
 "The subscription was canceled" = "구독이 취소되었습니다";
 "This task has expired" = "이 작업은 만료되었습니다";
-"Processing you photo" = "사진을 처리 중입니다";
+"Processing your photo" = "사진을 처리 중입니다";
 "Enlighten Tips" = "Enlighten 팁";
 "Verify receipt failed" = "수신 확인 실패";
 "Purchasing now" = "현재 구매 중입니다";

+ 1 - 1
TSLiveWallpaper/pt-BR.lproj/Localizable.strings

@@ -32,7 +32,7 @@
 "Payment Failed" = "Falha no pagamento";
 "The subscription was canceled" = "A assinatura foi cancelada";
 "This task has expired" = "Esta tarefa expirou";
-"Processing you photo" = "Processando sua foto";
+"Processing your photo" = "Processando sua foto";
 "Enlighten Tips" = "Dicas Iluminadoras";
 "Verify receipt failed" = "Falha na verificação do recibo";
 "Purchasing now" = "Comprando agora";

+ 1 - 1
TSLiveWallpaper/pt-PT.lproj/Localizable.strings

@@ -32,7 +32,7 @@
 "Payment Failed" = "Falha no pagamento";
 "The subscription was canceled" = "A assinatura foi cancelada";
 "This task has expired" = "Esta tarefa expirou";
-"Processing you photo" = "Processando sua foto";
+"Processing your photo" = "Processando sua foto";
 "Enlighten Tips" = "Dicas Iluminadoras";
 "Verify receipt failed" = "Falha na verificação do recibo";
 "Purchasing now" = "Comprando agora";

+ 1 - 1
TSLiveWallpaper/zh-Hant.lproj/Localizable.strings

@@ -25,7 +25,7 @@
 "Payment Failed" = "付款失敗";
 "The subscription was canceled" = "訂閱已被取消";
 "This task has expired" = "此任務已過期";
-"Processing you photo" = "正在處理您的照片";
+"Processing your photo" = "正在處理您的照片";
 "Enlighten Tips" = "啟發提示";
 "Verify receipt failed" = "驗證收據失敗";
 "Purchasing now" = "正在購買";